package com.eric.demo.instrumenter;

import com.google.monitoring.runtime.instrumentation.AllocationRecorder;

/**
 * @author guangyin.zhang
 * @since 2019/12/10
 */
public class Test {
    public static void main(String [] args) throws Exception {
        AllocationRecorder.addSampler((count, desc, newObj, size) -> {
            System.out.println("I just allocated the object " + newObj
                    + " of type " + desc + " whose size is " + size);
            if (count != -1) { System.out.println("It's an array of size " + count); }
        });
        for (int i = 0 ; i < 10; i++) {
            byte[] bytes = new byte[1024];
        }
    }
}
